<!DOCTYPE html>
<#assign ctx=Session.basePath>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>告警信息</title>
    <script>
        var shipid = '<#if shipid??>${shipid}<#else></#if>';
        var company =  '<#if company??>${company}<#else></#if>';
    </script>
    <link href="${ctx}/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <link href="${ctx}/easyui/themes/icon.css" rel="stylesheet" />
    <link href="${ctx}/inspiniain/font-awesome/css/font-awesome.css" rel="stylesheet">
    <script src="${ctx}/js/jquery-1.12.2.min.js"></script>
    <script src="${ctx}/lib/jquery.form.js"></script>
    <script src="${ctx}/easyui/jquery.easyui.min.js"></script>
    <script src="${ctx}/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="${ctx}/pagination/js/layer/layer.js"></script>
</head>
<body>

<div id="tb" style="padding:5px;height:auto">
    <div>
        标题:<input id="title" class="easyui-text" style="120px">
        <a href="#" class="easyui-linkbutton btn-search" iconCls="icon-search" style="width: 80px;">查找</a>
    </div>
</div>

<table id="dg"
       data-options="rownumbers:true,singleSelect:true,pagination:true,url:'${ctx}/manage/map/company/warning/ajax/data/page/list',method:'post',toolbar:'#tb',nowrap:false">
    <thead>
    <tr>
        <th data-options="field:'title',width:70">标题</th>
        <th data-options="field:'contents',width:90">内容</th>
        <th data-options="field:'warningtype',width:30">类型</th>
        <th data-options="field:'event',width:40,align:'center'">触发事件</th>
        <th data-options="field:'navigate',width:30,align:'center'">定位</th>
    </tr>
    </thead>
</table>
<script type="text/javascript">
    $(function () {
        loadAll();
        $(".btn-search").click(function () {
            $('#dg').datagrid("load",{
                title : $("#title").val()
            })
        });
    });
    function loadAll() {
        var pager = $('#dg').datagrid({
            fitColumns: true,
            fit: true,
            loadFilter: function (data) {
                //alert(data)
                if (data != null && data.rows != null) {
                    for (var i = 0; i < data.rows.length; i++) {
                        var record = data.rows[i];
                        var warningtype = record.warningtype;
                        var event = record.event;
                        var warningText = "";
                        if(warningtype == "Point"){
                            warningText = "点";
                        }
                        if(warningtype == "LineString"){
                            warningText = "线";
                        }
                        if(warningtype == "Polygon"){
                            warningText = "面";
                        }
                        record.event = (event == "1" ? "靠近" : "进入");
                        record.warningtype = warningText;
                        record.navigate = "<a href='#' onclick='locationMap(\"" + record.guid + "\")'><i style='font-size:20px;' class='fa fa-map-marker' aria-hidden='true'></i></a>";
                    }
                }
                return data;
            }
        })
    };	// get the pager of datagrid

    function locationMap(guid) {
        console.log(guid);
        window.parent.locServer(guid,'warning');
    }
</script>


</body>
</html>